﻿@model ProductDetailsModel
@using SDF.Web.Models.Catalog;
@{
    Html.AddScriptParts("~/Scripts/jquery.magnific-popup.min.js");
    Html.AddCssFileParts("~/Content/magnific-popup/magnific-popup.css");
}
<div class="gallery">
    <div class="picture">
        @if (Model.DefaultPictureZoomEnabled)
        {
            <a href="@Model.DefaultPictureModel.FullSizeImageUrl" title="@Model.DefaultPictureModel.Title" id="main-product-img-lightbox-anchor-@Model.Id">
                <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" itemprop="image" id="main-product-img-@Model.Id" />
            </a>
            <script type="text/javascript">
                $(document).ready(function () {
                    $('#main-product-img-lightbox-anchor-@Model.Id').magnificPopup(
                    {
                        type: 'image',
                        removalDelay: 300,
                        gallery: {
                            enabled: true,
                            tPrev: '@T("Media.MagnificPopup.Previous")',
                            tNext: '@T("Media.MagnificPopup.Next")',
                            tCounter: '@T("Media.MagnificPopup.Counter")'
                        },
                        tClose: '@T("Media.MagnificPopup.Close")',
                        tLoading: '@T("Media.MagnificPopup.Loading")'
                    });
                });
            </script>
        }
        else
        {
            <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" itemprop="image" id="main-product-img-@Model.Id" />
        }
    </div>
    @if (Model.PictureModels.Count > 1)
    {
        <div class="picture-thumbs">
            @foreach (var picture in Model.PictureModels)
            {
                <a class="thumb-popup-link" href="@picture.FullSizeImageUrl" title="@picture.Title">
                    <img src="@picture.ImageUrl" alt="@picture.AlternateText" title="@picture.Title" />
                </a>
            }
        </div>
        <script type="text/javascript">
            $(document).ready(function () {
                $('.thumb-popup-link').magnificPopup(
                {
                    type: 'image',
                    removalDelay: 300,
                    gallery: {
                        enabled: true,
                        tPrev: '@T("Media.MagnificPopup.Previous")',
                        tNext: '@T("Media.MagnificPopup.Next")',
                        tCounter: '@T("Media.MagnificPopup.Counter")'
                    },
                    tClose: '@T("Media.MagnificPopup.Close")',
                    tLoading: '@T("Media.MagnificPopup.Loading")'
                });
            });
        </script>
    }
</div>